Skip to content

*: add TiDB workload repository #20127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

hfxsd
Copy link
Collaborator

@hfxsd hfxsd commented Mar 27, 2025

First-time contributors' checklist

What is changed, added or deleted? (Required)

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Copy link

ti-chi-bot bot commented Mar 27, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from hfxsd, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 27, 2025
@hfxsd hfxsd self-assigned this Mar 27, 2025
@hfxsd hfxsd added translation/from-docs This PR is translated from a PR in pingcap/docs. v9.0-beta.1 This PR/issue applies to TiDB v9.0-beta.1. and removed contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. labels Mar 27, 2025
@hfxsd hfxsd requested review from bb7133, songrijie and lilin90 March 27, 2025 02:32
@hfxsd hfxsd added the type/compatibility-or-feature-change This PR involves compatibility changes or feature behavior changes. label Mar 31, 2025
@hfxsd hfxsd requested a review from qiancai March 31, 2025 03:59
@hfxsd
Copy link
Collaborator Author

hfxsd commented Apr 9, 2025

/bot-review

Copy link

github-actions bot commented Apr 9, 2025

✅ AI review completed, 11 comments generated.

workloadrepo.md Outdated

## 快照采样过程(默认每小时)

快照采样过程每 15 分钟到 2 小时运行一次,从存储累计指标的内存表中采样数据。快照由指定时间间隔内的某个 TiDB 节点发起,过程如下:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
快照采样过程每 15 分钟到 2 小时运行一次,从存储累计指标的内存表中采样数据。快照由指定时间间隔内的某个 TiDB 节点发起,过程如下:
快照采样过程每 15 分钟到 2 小时运行一次(默认每小时),从存储累计指标的内存表中采样数据。快照由指定时间间隔内的某个 TiDB 节点发起,过程如下:

Copy link
Collaborator

@qiancai qiancai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

Comment on lines +44 to +48
| `TIDB_INDEX_USAGE` | `HIST_TIDB_INDEX_USAGE` | 索引使用统计信息 |
| `TIDB_STATEMENTS_STATS` | `HIST_TIDB_STATEMENTS_STATS` | 语句统计信息 |
| `CLIENT_ERRORS_SUMMARY_BY_HOST` | `HIST_CLIENT_ERRORS_SUMMARY_BY_HOST` | 按主机的客户端错误摘要 |
| `CLIENT_ERRORS_SUMMARY_BY_USER` | `HIST_CLIENT_ERRORS_SUMMARY_BY_USER` | 按用户的客户端错误摘要 |
| `CLIENT_ERRORS_SUMMARY_GLOBAL` | `HIST_CLIENT_ERRORS_SUMMARY_GLOBAL` | 全局客户端错误摘要 |
Copy link
Collaborator

@qiancai qiancai Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `TIDB_INDEX_USAGE` | `HIST_TIDB_INDEX_USAGE` | 索引使用统计信息 |
| `TIDB_STATEMENTS_STATS` | `HIST_TIDB_STATEMENTS_STATS` | 语句统计信息 |
| `CLIENT_ERRORS_SUMMARY_BY_HOST` | `HIST_CLIENT_ERRORS_SUMMARY_BY_HOST` | 按主机的客户端错误摘要 |
| `CLIENT_ERRORS_SUMMARY_BY_USER` | `HIST_CLIENT_ERRORS_SUMMARY_BY_USER` | 按用户的客户端错误摘要 |
| `CLIENT_ERRORS_SUMMARY_GLOBAL` | `HIST_CLIENT_ERRORS_SUMMARY_GLOBAL` | 全局客户端错误摘要 |
| [`TIDB_INDEX_USAGE`](/information-schema/information-schema-tidb-index-usage.md) | `HIST_TIDB_INDEX_USAGE` | 索引使用统计信息 |
| [`TIDB_STATEMENTS_STATS`](/statement-summary-tables.md) | `HIST_TIDB_STATEMENTS_STATS` | 语句统计信息 |
| [`CLIENT_ERRORS_SUMMARY_BY_HOST`](/information-schema/client-errors-summary-by-host.md) | `HIST_CLIENT_ERRORS_SUMMARY_BY_HOST` | 基于主机客户端的错误摘要 |
| [`CLIENT_ERRORS_SUMMARY_BY_USER`](/information-schema/client-errors-summary-by-user.md) | `HIST_CLIENT_ERRORS_SUMMARY_BY_USER` | 基于用户客户端的错误摘要 |
| [`CLIENT_ERRORS_SUMMARY_GLOBAL`](/information-schema/client-errors-summary-global.md) | `HIST_CLIENT_ERRORS_SUMMARY_GLOBAL` | 基于全局客户端的错误摘要 |

快照采样过程每 15 分钟到 2 小时运行一次(默认每小时),从存储累计指标的内存表中采样数据。快照由指定时间间隔内的某个 TiDB 节点发起,过程如下:

1. 从发起节点向 `HIST_SNAPSHOTS` 表插入一行,记录快照 ID、开始和结束时间戳以及服务器版本信息。
2. 在每个 TiDB 节点上,将源表中的所有行复制到带有 `HIST_` 前缀的对应历史表中。复制的数据包括源表中的原始列以及用于时间戳、实例 ID 和快照 ID 的附加列。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. 在每个 TiDB 节点上,将源表中的所有行复制到带有 `HIST_` 前缀的对应历史表中。复制的数据包括源表中的原始列以及用于时间戳、实例 ID 和快照 ID 的附加列。
2. 在每个 TiDB 节点上,将源表中的所有行复制到带有 `HIST_` 前缀的对应目标表中。复制的数据包括源表中的原始列以及用于记录时间戳、实例 ID 和快照 ID 的附加列。


从以下表中采样数据:

| 表名 | 目标表 | 描述 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| 表名 | 目标表 | 描述 |
| 源表 | 目标表 | 描述 |


从以下表中采样数据:

| 表名 | 目标表 | 描述 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| 表名 | 目标表 | 描述 |
| 源表 | 目标表 | 描述 |


基于时间的采样间隔可设置为 1 秒到 600 秒之间的任意时间,从各个记录瞬时状态的系统表中采样数据。

当基于时间的采样过程运行时,源表中的所有行都会被复制到带有 `HIST_` 前缀的对应历史表中。复制的数据包括源表中的原始列以及用于时间戳和实例 ID 的附加列。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
当基于时间的采样过程运行时,源表中的所有行都会被复制到带有 `HIST_` 前缀的对应历史表中。复制的数据包括源表中的原始列以及用于时间戳和实例 ID 的附加列。
当基于时间的采样过程运行时,源表中的所有行都会被复制到带有 `HIST_` 前缀的对应目标表中。复制的数据包括源表中的原始列以及用于记录时间戳和实例 ID 的附加列。

```sql
ADMIN WORKLOAD REPOSITORY TAKE SNAPSHOT;
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

运行这个语句是否有权限要求,如果有,这里需要补充下

## 手动快照

请注意,虽然快照采样过程会根据配置的时间间隔自动运行,但你也可以使用以下 SQL 语句触发手动快照:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL 语句文档里需要新增一篇介绍这个语句吗
image


## 数据保留

系统会根据保留期设置自动清除数据,并使用分区进行高效的数据管理。
Copy link
Collaborator

@qiancai qiancai Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
系统会根据保留期设置自动清除数据,并使用分区进行高效的数据管理。
Workload Repository 中历史数据默认保留 7 天。系统会根据保留期设置自动清除数据,并使用分区进行高效的数据管理。

## 注意事项

- 启用 Workload Repository 可能会对系统性能产生轻微影响。
- 采样间隔设置得过低可能会增加系统开销。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 采样间隔设置得过低可能会增加系统开销
- 采样间隔设置得过短可能会增加系统开销


快照采样过程每 15 分钟到 2 小时运行一次(默认每小时),从存储累计指标的内存表中采样数据。快照由指定时间间隔内的某个 TiDB 节点发起,过程如下:

1. 从发起节点向 `HIST_SNAPSHOTS` 表插入一行,记录快照 ID、开始和结束时间戳以及服务器版本信息。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. 从发起节点向 `HIST_SNAPSHOTS` 表插入一行,记录快照 ID、开始和结束时间戳以及服务器版本信息。
1. 从发起节点向 `WORKLOAD_SCHEMA.HIST_SNAPSHOTS` 表插入一行,记录快照 ID、开始和结束时间戳以及服务器版本信息。

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 14, 2025
Copy link

ti-chi-bot bot commented Apr 14, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-14 06:46:02.466899541 +0000 UTC m=+2670856.151135632: ☑️ agreed by qiancai.

SET GLOBAL tidb_workload_repository_retention_days = 30;
```

此变量的较高值允许更长的数据保留时间,这可能有助于工作负载分析,但会增加存储需求。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
此变量的较高值允许更长的数据保留时间,这可能有助于工作负载分析,但会增加存储需求。
此变量的值越高,数据保留时间越长,这可能有助于工作负载分析,但会增加存储需求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-1-more-lgtm Indicates a PR needs 1 more LGTM. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. translation/from-docs This PR is translated from a PR in pingcap/docs. type/compatibility-or-feature-change This PR involves compatibility changes or feature behavior changes. v9.0-beta.1 This PR/issue applies to TiDB v9.0-beta.1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants